package com.ihr360.payroll.model.dto.attendance.template;


import com.ihr360.commons.model.entity.NumberIdWithTime;
import com.ihr360.commons.model.type.WorkHourType;
import com.ihr360.payroll.model.code.CycleStandard;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.MapKeyClass;
import javax.persistence.MapKeyJoinColumn;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/** 工时模板(咱不确定是否有用) */
@Entity
@NoArgsConstructor
@Data
public class WorkHourTemplate extends NumberIdWithTime<Long> {

    private static final long serialVersionUID = -4997992290027927213L;

    /** 名称 */
    @Column(length = 50, nullable = false)
    private String name;

    /** 是否启用 */
    private boolean enabled = true;

    /** 工时类型 */
    @Column(nullable = false, length = 20)
    @Enumerated(EnumType.STRING)
    private WorkHourType type = WorkHourType.STANDARD;


    /** 综合工时类型 */
    @ElementCollection
    @CollectionTable(joinColumns = @JoinColumn(name = "template_id"))
    @MapKeyJoinColumn(name = "cycleStandard_id")
    @MapKeyClass(CycleStandard.class)
    @Column(name = "value")
    private Map<CycleStandard, Integer> standardWorkHours = new HashMap<>();

    /** 计薪标准(月) */
    private Integer monthWorkHour;

    /** 计薪标准(日) */
    private Integer dailyWorkHour;

    /** 备注 */
    @Column(length = 1000)
    private String remark;

    /** 生效日期 */
    @Column(nullable = false)
    private Date effectiveAt;

    /** 失效日期 */
    private Date invalidAt;

}
